home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / gameboy / vgb.c < prev    next >
C/C++ Source or Header  |  1995-12-30  |  2KB  |  93 lines

  1. /** VGB: portable GameBoy emulator ***************************/
  2. /**                                                         **/
  3. /**                           VGB.c                         **/
  4. /**                                                         **/
  5. /** This file contains generic main() procedure statrting   **/
  6. /** the emulation.                                          **/
  7. /**                                                         **/
  8. /** Copyright (C) Marat Fayzullin 1995                      **/
  9. /**     You are not allowed to distribute this software     **/
  10. /**     commercially. Please, notify me, if you make any    **/
  11. /**     changes to this file.                               **/
  12. /*************************************************************/
  13.  
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <signal.h>
  19.  
  20. #include "GB.h"
  21. #include "Help.h"
  22.  
  23.  
  24. extern char *Title;
  25. extern int   UseSHM;
  26. extern int   SaveCPU;
  27. extern word OldTrap;
  28. BPTR lock;
  29.  
  30. main(void)
  31. {
  32. LONG ArgPtrs[5]={0};
  33. struct RDArgs *Args;
  34. STRPTR filename_buf;
  35.  
  36.   TrapBadOps=1;LineDelay=0; 
  37.   VPeriod=10000;UPeriod=2;IntSync=1;
  38.   Verbose=5;
  39.  
  40.     if(Args = ReadArgs("Verbose/K/N,VP=VPeriod/K/N,UP=UPeriod/K/N,Trap/K,Help/S",ArgPtrs,NULL))
  41.     {
  42.         if(OPT_VERBOSE) Verbose = (int)(*OPT_VERBOSE);
  43.         if(OPT_VPER) VPeriod = (int)(*OPT_VPER);
  44.         if(OPT_UPER) UPeriod = (int)(*OPT_UPER);
  45.         if(OPT_TRAP) sscanf(OPT_TRAP,"%hx",&Trap);
  46.         if(OPT_HELP) {puts(HelpText); FreeArgs(Args); exit(0);}
  47.  
  48.         FreeArgs(Args);
  49.         if((filename_buf = ReqFile()) == NULL) exit(0);
  50.  
  51.         if(!InitMachine()) return(1);
  52.         OldTrap=Trap;
  53.         StartGB(filename_buf);
  54.         TrashGB();
  55.         TrashMachine();
  56.  
  57.         FreeVec(filename_buf);
  58.         UnLock(lock);
  59.  
  60.         return(0);
  61.     }
  62. }
  63.  
  64.  
  65. STRPTR ReqFile(void)
  66. {
  67. struct FileRequester *AslReq;
  68. STRPTR file=NULL;
  69.  
  70.     if(AslReq = (struct FileRequester*)AllocAslRequestTags(ASL_FileRequest,
  71.             ASLFR_TitleText,"Select a cartridge!",
  72.             ASLFR_PositiveText,"Play!",
  73.             ASLFR_NegativeText,"Suxx!",
  74.             ASLFR_RejectIcons,TRUE,
  75.             TAG_END))
  76.     {
  77.         if(AslRequest(AslReq,NULL))
  78.         {
  79.             if(file = AllocVec(strlen(AslReq->fr_File)+1,MEMF_ANY))
  80.             {
  81.                 strcpy(file,AslReq->fr_File);
  82.                 if(strlen(AslReq->fr_Drawer))
  83.                 {
  84.                     lock = Lock(AslReq->fr_Drawer,ACCESS_READ);
  85.                     CurrentDir(lock);
  86.                 }
  87.             }
  88.         }
  89.         FreeAslRequest((APTR)AslReq);
  90.     }
  91.     return file;
  92. }
  93.